Skip to content

Commit

Permalink
fix(ts): support ts 3.9 on windows in the typescript-transpiler (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed May 18, 2020
1 parent 239cc27 commit 0fab74f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -8,12 +8,13 @@ on:

jobs:
build_and_test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x]
os: ['ubuntu-latest', 'windows-latest']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
Expand All @@ -29,17 +30,18 @@ jobs:
run: npm run all

e2e:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']

steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm install
- name: Build packages
run: npm run build
- name: Run e2e tests
run: npm run e2e

6 changes: 3 additions & 3 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/package.json
Expand Up @@ -34,7 +34,7 @@
"ts-jest": "^25.4.0",
"ts-loader": "^7.0.3",
"ts-node": "~7.0.0",
"typescript": "~3.7.2",
"typescript": "~3.9.2",
"webpack": "~4.41.2"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions e2e/test/jest-react/stryker.conf.js
Expand Up @@ -4,6 +4,7 @@ module.exports = function (config) {
mutator: "javascript",
transpilers: [],
reporters: ["event-recorder"],
tempDirName: "stryker-tmp",
coverageAnalysis: "off",
timeoutMS: 60000, // High timeout to survive high build server load. Mutants created here should never timeout
mutate: ["src/{Alert,Badge,Breadcrumb}.js"],
Expand Down
3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -27,7 +27,6 @@
"eslint-plugin-prettier": "3.1.3",
"execa": "^3.2.0",
"glob": "^7.1.1",
"if-node-version": "^1.1.1",
"install-local": "~2.0.0",
"jasmine": "^3.1.0",
"jasmine-core": "^3.1.0",
Expand All @@ -38,11 +37,9 @@
"nyc": "^15.0.0",
"prettier": "2.0.5",
"rimraf": "^3.0.0",
"rxjs": "^6.4.0",
"sinon": "^9.0.0",
"sinon-chai": "3.5.0",
"source-map-support": "^0.5.6",
"ts-json-schema-generator": "^0.68.0",
"typescript": "~3.9.2"
},
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions packages/typescript/src/transpiler/TranspilingLanguageService.ts
Expand Up @@ -34,7 +34,7 @@ export default class TranspilingLanguageService {
getLogger: LoggerFactoryMethod
) {
this.compilerOptions = this.adaptCompilerOptions(compilerOptions);
rootFiles.forEach((file) => (this.files[file.name] = new ScriptFile(file.name, file.textContent)));
rootFiles.forEach((file) => (this.files[normalizeFileForTypescript(file.name)] = new ScriptFile(file.name, file.textContent)));
const host = this.createLanguageServiceHost();
this.languageService = ts.createLanguageService(host);
this.logger = getLogger(TranspilingLanguageService.name);
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class TranspilingLanguageService {
* @param mutantCandidate The mutant used to replace the original source
*/
public replace(replacements: readonly File[]) {
replacements.forEach((replacement) => this.files[replacement.name].replace(replacement.textContent));
replacements.forEach((replacement) => this.files[normalizeFileForTypescript(replacement.name)].replace(replacement.textContent));
}

public getSemanticDiagnostics(files: readonly File[]) {
Expand All @@ -79,7 +79,7 @@ export default class TranspilingLanguageService {
* If all output files are bundled together, only returns the output file once using the first file as key
*/
public emit(fileName: string): EmitOutput {
const emittedFiles = this.languageService.getEmitOutput(fileName).outputFiles;
const emittedFiles = this.languageService.getEmitOutput(normalizeFileForTypescript(fileName)).outputFiles;
const jsFile = emittedFiles.find(isJavaScriptFile);
const mapFile = emittedFiles.find(isMapFile);
if (jsFile) {
Expand All @@ -101,7 +101,9 @@ export default class TranspilingLanguageService {
getCurrentDirectory: () => path.resolve(this.projectDirectory),
getDefaultLibFileName: ts.getDefaultLibFileName,
getDirectories: ts.sys.getDirectories,
getScriptFileNames: () => Object.keys(this.files),
getScriptFileNames: () => {
return Object.keys(this.files);
},
getScriptSnapshot: (fileName) => {
this.pullFileIntoMemoryIfNeeded(fileName);
return this.files[fileName] && ts.ScriptSnapshot.fromString(this.files[fileName].content);
Expand Down
2 changes: 1 addition & 1 deletion packages/wct-runner/package.json
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"scripts": {
"test": "cross-env LAUNCHPAD_BROWSERS=chrome nyc --reporter=html --report-dir=reports/coverage --lines 95 --functions 95 --branches 95 npm run mocha",
"mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && if-node-version \">=8\" mocha --timeout 120000 --exit \"test/helpers/**/*.js\" \"test/integration/**/*.js\"",
"mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && mocha --timeout 120000 --exit \"test/helpers/**/*.js\" \"test/integration/**/*.js\"",
"stryker": "node ../core/bin/stryker run"
},
"repository": {
Expand Down

0 comments on commit 0fab74f

Please sign in to comment.