Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 16: cannot find types (Cannot find name 'Then'.) #20

Open
jimschmit opened this issue Oct 24, 2023 · 2 comments
Open

Angular 16: cannot find types (Cannot find name 'Then'.) #20

jimschmit opened this issue Oct 24, 2023 · 2 comments

Comments

@jimschmit
Copy link

Describe the bug
After upgrading to Angular v16, the tests no longer run.
An example of a thrown error in the terminal is the following one:
error TS2304: Cannot find name 'Given'.

To Reproduce

  1. Update Angular to v16
  2. run the angular unit tests (npm run test)

Expected behavior
Tests should still recognise jasmine given types

Desktop (please complete the following information):

  • OS: Mac OS Sonoma

Additional context

  • tsconfig.ts:
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "include": [
    "src",
    "node_modules/cypress"
  ],
  "exclude": [
    "node_modules/cypress"
  ],
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@core/*": [
        "src/app/core/*"
      ],
      "@blocks/*": [
        "src/app/blocks/*"
      ],
      "@features/*": [
        "src/app/features/*"
      ],
      "@shared/*": [
        "src/app/shared/*"
      ],
      "@app/*": [
        "src/app/*"
      ]
    },
    "typeRoots": [
      "node_modules/@types",
      "node_modules/@hirez_io"
    ],
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ES2022",
    "module": "es2020",
    "lib": [
      "es2020",
      "dom",
      "dom.iterable"
    ],
    "allowSyntheticDefaultImports": true,
    "useDefineForClassFields": false
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

  • tsconfig.spec.ts
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": ["jasmine", "@hirez_io/jasmine-given"]
  },
  "files": ["src/test.ts", "src/polyfills.ts"],
  "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}

  • test.ts
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js';
import 'zone.js/testing';

import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { autoUnsubscribe } from '@hirez_io/observer-spy';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

autoUnsubscribe();

@dmitrii-konoplyannikov-napier

I have the same issue after upgrading angular to v16

@dmitrii-konoplyannikov-napier

@shairez I suppose the problem appears after upgrading typescript to version 5.x.x .
@jimschmit try to downgrade typescript to "typescript": "~4.9.3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants