Skip to content

Commit 13f10de

Browse files
committed
test: update code fixes spec to work with esm-cjs interop lint (#48731)
The TSLint rule for ESM/CJS interop was apparently not working for a short period of time due to diverging TypeScript versions. This commit fixes the lint warning to replace the type-only import with a default import. Even thoughn not striclty needed for types- the rule enforces a default import as that is the safer approach for runtime imported symbols. Also the rule is updated to not disallow `cluster` anymore. The types for cluster do no allow for e.g. `cluster.Worker` if cluster refers to the default import. The whole lint rule is not strictly needed anymore since we build & test with ESM in this repo now! PR Close #48731
1 parent 1898190 commit 13f10de

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/language-service/test/code_fixes_spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {initMockFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
1010
import {spawn} from 'child_process';
11-
import {CodeAction} from 'typescript';
11+
import ts from 'typescript';
1212

1313
import {FixIdForCodeFixesAll} from '../src/codefixes/utils';
1414
import {createModuleAndProjectWithDeclarations, LanguageServiceTestEnv} from '../testing';
@@ -24,7 +24,7 @@ describe('code fixes', () => {
2424
const files = {
2525
'app.ts': `
2626
import {Component, NgModule} from '@angular/core';
27-
27+
2828
@Component({
2929
templateUrl: './app.html'
3030
})
@@ -59,7 +59,7 @@ describe('code fixes', () => {
5959
const files = {
6060
'app.ts': `
6161
import {Component, NgModule} from '@angular/core';
62-
62+
6363
@Component({
6464
templateUrl: './app.html'
6565
})
@@ -91,7 +91,7 @@ describe('code fixes', () => {
9191
const files = {
9292
'app.ts': `
9393
import {Component, NgModule} from '@angular/core';
94-
94+
9595
@Component({
9696
templateUrl: './app.html'
9797
})
@@ -115,7 +115,7 @@ describe('code fixes', () => {
115115
const files = {
116116
'app.ts': `
117117
import {Component, NgModule} from '@angular/core';
118-
118+
119119
@Component({
120120
template: '{{tite}}{{bannr}}',
121121
})
@@ -165,7 +165,7 @@ describe('code fixes', () => {
165165
const files = {
166166
'app.ts': `
167167
import {Component, NgModule} from '@angular/core';
168-
168+
169169
@Component({
170170
templateUrl: './app.html'
171171
})
@@ -197,7 +197,7 @@ describe('code fixes', () => {
197197
const files = {
198198
'app.ts': `
199199
import {Component, NgModule} from '@angular/core';
200-
200+
201201
@Component({
202202
template: '<input ([ngModel])="title"><input ([value])="title">',
203203
})
@@ -493,7 +493,7 @@ function actionChangesMatch(
493493
// Returns the ActionChanges for all changes in the given code actions, collapsing whitespace into a
494494
// single space and trimming at the ends.
495495
function allChangesForCodeActions(
496-
fileContents: string, codeActions: readonly CodeAction[]): ActionChanges {
496+
fileContents: string, codeActions: readonly ts.CodeAction[]): ActionChanges {
497497
// Replace all whitespace characters with a single space, then deduplicate spaces and trim.
498498
const collapse = (s: string) => s.replace(/\s/g, ' ').replace(/\s{2,}/g, ' ').trim();
499499
let allActionChanges: ActionChanges = {};

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"semver",
2929
"yargs",
3030
"glob",
31-
"cluster",
3231
"convert-source-map"
3332
],
3433
// The following CommonJS modules appear to have a default export available (due to the `esModuleInterop` flag),

0 commit comments

Comments
 (0)