Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/postcss-linaria/src/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ class LinariaStringifier extends Stringifier {
) {
return node.raws.linariaBetween;
}
return super.raw(node, own, detect);
// postcss 8.5 declares the result as `boolean | string`, 8.4 as `string`.
// At runtime it is a boolean for the `semicolon` raw that the inherited
// `body` reads, so `string` is only the signature that the calls in this
// class rely on. The base result is returned unchanged.
return super.raw(node, own, detect) as string;
}

/** @inheritdoc */
Expand All @@ -400,7 +404,10 @@ class LinariaStringifier extends Stringifier {
return `${node.raws[linariaProp]}`;
}

return super.rawValue(node, prop);
// postcss 8.5 declares the result as `number | string`, 8.4 as `string`.
// The base result is returned unchanged; the fields read through
// `rawValue` (`params`, `value` and `selector`) are strings.
return super.rawValue(node, prop) as string;
}

/** @inheritdoc */
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function collect(
let removedNodesFromOther = 0;
criticalRule.each((childRule: ChildNode, index: number) => {
if (isCritical(childRule)) {
otherRule.nodes[index - removedNodesFromOther]?.remove();
otherRule.nodes?.[index - removedNodesFromOther]?.remove();
removedNodesFromOther += 1;
} else {
childRule.remove();
Expand All @@ -102,10 +102,10 @@ export default function collect(

rule.remove();

if (criticalRule.nodes.length > 0) {
if (criticalRule.nodes?.length) {
critical.append(criticalRule);
}
if (otherRule.nodes.length > 0) {
if (otherRule.nodes?.length) {
other.append(otherRule);
}
};
Expand Down
56 changes: 56 additions & 0 deletions scripts/typecheck-postcss-8-5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
# Typechecks the workspace packages that use postcss (@linaria/server,
# @linaria/postcss-linaria and @linaria/atomic) against postcss 8.5.23.
#
# The committed manifests and lockfile still resolve postcss to 8.4.31, so the
# script swaps in the ones of the dependabot update to 8.5.23, installs with
# --ignore-scripts, runs `typecheck` of the three packages (`tsc --noEmit
# --composite false`, after the declarations of their dependencies are built)
# and puts the committed manifests, lockfile and install back on exit.
#
# Exit code: 0 when the packages typecheck, non-zero otherwise.
set -eu

# The head of the dependabot pull request that updates postcss to 8.5.23.
update=05b0d4ca86d3cd33a46425ad124c6308be3531e0
files="pnpm-lock.yaml packages/atomic/package.json packages/postcss-linaria/package.json packages/server/package.json"

cd "$(dirname "$0")/.."

git cat-file -e "$update^{commit}" || {
echo "commit $update is not in this repository" >&2
exit 2
}

# Plain output: the failure signature is matched against it.
export NO_COLOR=1 FORCE_COLOR=0

backup=$(mktemp -d)

restore() {
status=$?
trap - EXIT
for file in $files; do
cp "$backup/$(echo "$file" | tr / _)" "$file"
done
rm -rf "$backup"
pnpm install --frozen-lockfile --ignore-scripts >/dev/null 2>&1 || true
exit "$status"
}
trap restore EXIT

for file in $files; do
cp "$file" "$backup/$(echo "$file" | tr / _)"
git show "$update:$file" >"$file"
done

pnpm install --frozen-lockfile --ignore-scripts

pnpm --filter ./packages/atomic --filter ./packages/postcss-linaria --filter ./packages/server list postcss --depth 0

# --continue: report the errors of every package, not only of the first one
# that fails.
pnpm exec turbo run typecheck --force --continue \
--filter=@linaria/atomic \
--filter=@linaria/postcss-linaria \
--filter=@linaria/server
Loading