Reputation: 135
I have a Firebase Functions project that has "type" set to "module" in package.json so that I can use ES6 syntax. Some of the files import data from another json file with a line like:
import oAuth2Data from './client_secrets.json' assert { type: 'json' };
Recently, in my server logs, I noticed a warning from Firebase that: 'assert' is being deprecated...use 'with' instead. Unfortunately, VSCode gives me the error "'with' is not supported in strict mode" which I believe is necessary to use type:module. Is there another option that allows me to continue using strict mode?
Upvotes: 1
Views: 31
Reputation: 222979
import..with
is the correct syntax, as another answer suggests, so it should be:
import oAuth2Data from './client_secrets.json' with { type: 'json' };
This is TypeScript error, that it occurs means that it's caused by TypeScript version that is too old, so it's parsed as:
import oAuth2Data from './client_secrets.json';
with { type: 'json' }
Since the question doesn't mention that the project uses TypeScript, and it happens only in IDE, the problem is specific to the latter. VS Code heavily relies on TS even in JS-only projects. This can be solved by updating VS Code and its internal TypeScript, or globally installed TypeScript, or in-project TypeScript (in case there is any). TS version that VSC uses for the project is configurable.
Upvotes: 1
Reputation: 203514
The with
statement is forbidden in strict mode, but the with
import attribute isn't.
Upvotes: 2