Skip to content

Commit 89f6f6b

Browse files
committed
Merge branch 'main' into gabritto/switchsnippet
2 parents 3b92638 + b553aff commit 89f6f6b

27 files changed

+1306
-239
lines changed

.github/workflows/ci.yml

+64
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,70 @@ jobs:
8686
- name: Build src
8787
run: npx hereby build-src
8888

89+
smoke:
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v3
94+
- uses: actions/setup-node@v3
95+
with:
96+
node-version: "*"
97+
check-latest: true
98+
- run: npm ci
99+
100+
- run: npx hereby lkg
101+
- run: |
102+
npm pack
103+
mv typescript*.tgz typescript.tgz
104+
echo "PACKAGE=$PWD/typescript.tgz" >> $GITHUB_ENV
105+
106+
- name: Smoke test
107+
run: |
108+
cd "$(mktemp -d)"
109+
npm init --yes
110+
npm install $PACKAGE tslib
111+
112+
echo "Testing tsc..."
113+
npx tsc --version
114+
115+
echo "Testing tsserver..."
116+
echo '{"seq": 1, "command": "status"}' | npx tsserver
117+
118+
cat > smoke.js << 'EOF'
119+
console.log(`Testing ${process.argv[2]}...`);
120+
const { __importDefault, __importStar } = require("tslib");
121+
const ts = require(process.argv[2]);
122+
123+
// See: https://github.com./microsoft/TypeScript/pull/51474#issuecomment-1310871623
124+
const fns = [
125+
[() => ts.version, true],
126+
[() => ts.default.version, false],
127+
[() => __importDefault(ts).version, false],
128+
[() => __importDefault(ts).default.version, true],
129+
[() => __importStar(ts).version, true],
130+
[() => __importStar(ts).default.version, true],
131+
];
132+
133+
for (const [fn, shouldSucceed] of fns) {
134+
let success = false;
135+
try {
136+
success = !!fn();
137+
}
138+
catch {}
139+
const status = success ? "succeeded" : "failed";
140+
if (success === shouldSucceed) {
141+
console.log(`${fn.toString()} ${status} as expected.`);
142+
}
143+
else {
144+
console.log(`${fn.toString()} unexpectedly ${status}.`);
145+
process.exitCode = 1;
146+
}
147+
}
148+
console.log("ok");
149+
EOF
150+
151+
node ./smoke.js typescript
152+
node ./smoke.js typescript/lib/tsserverlibrary
89153
90154
misc:
91155
runs-on: ubuntu-latest

package-lock.json

+56-81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/builder.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,13 @@ function createBuilderProgramState(newProgram: Program, getCanonicalFileName: Ge
313313
});
314314

315315
// If the global file is removed, add all files as changed
316-
if (useOldState && forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => (outFilePath || info.affectsGlobalScope) && !state.fileInfos.has(sourceFilePath))) {
316+
if (useOldState && forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => {
317+
if (state.fileInfos.has(sourceFilePath)) return false;
318+
if (outFilePath || info.affectsGlobalScope) return true;
319+
// if file is deleted we need to write buildInfo again
320+
state.buildInfoEmitPending = true;
321+
return false;
322+
})) {
317323
BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
318324
.forEach(file => addFileToChangeSet(state, file.resolvedPath));
319325
}

src/compiler/builderState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ExportedModulesFromDeclarationEmit, GetCanonicalFileName, getDirectoryPath, getSourceFileOfNode,
44
isDeclarationFileName, isExternalOrCommonJsModule, isGlobalScopeAugmentation, isJsonSourceFile,
55
isModuleWithStringLiteralName, isStringLiteral, mapDefined, mapDefinedIterator, ModuleDeclaration,
6-
ModuleKind, outFile, OutputFile, Path, Program, some, SourceFile, StringLiteralLike, Symbol,
6+
ModuleKind, outFile, OutputFile, Path, Program, ResolutionMode, some, SourceFile, StringLiteralLike, Symbol,
77
toPath, TypeChecker,
88
} from "./_namespaces/ts";
99

@@ -75,7 +75,7 @@ export namespace BuilderState {
7575
readonly version: string;
7676
signature: string | undefined;
7777
affectsGlobalScope: true | undefined;
78-
impliedFormat: SourceFile["impliedNodeFormat"];
78+
impliedFormat: ResolutionMode;
7979
}
8080

8181
export interface ReadonlyManyToManyPathMap {

0 commit comments

Comments
 (0)