d.ts. files for lib/umd/languageFacts aren't included in npm package
orta opened this issue · 7 comments
vs
- https://unpkg.com/browse/vscode-html-languageservice@3.0.3/lib/umd/languageFacts/data/
- https://unpkg.com/browse/vscode-html-languageservice@3.0.3/lib/umd/
Seeing this error as a client on 3.0.3 (latest prod):
> svelte-language-server
$ tsc
node_modules/vscode-html-languageservice/lib/umd/languageFacts/data/html5.d.ts:1:34 - error TS7016: Could not find a declaration file for module '../dataProvider'. '/Users/ortatherox/dev/svelte/language-tools/node_modules/vscode-html-languageservice/lib/umd/languageFacts/dataProvider.js' implicitly has an 'any' type.
1 import { HTMLDataProvider } from '../dataProvider';
~~~~~~~~~~~~~~~~~
Found 1 error.
But the same issue existing on 4.0.0 also: https://unpkg.com/browse/vscode-html-languageservice@4.0.0-next.5/lib/umd/languageFacts/
It looks like this is on purpose from the .npmignore
- I wonder if the bug then is that lib/umd/languageFacts/data/html5.d.ts
even exists at all then
Looks like this section is removed in the 3.0.4-betas - will give those a run
Looking tricky, the codebase I'm looking at pulls a lot of the html data out of this package's privates, and there doesn't seem to be a 1:1 correlation with the new webCustomData. Going to see if I can just pull some of this from the Vetur source code.
import { HTML5_GLOBAL_ATTRIBUTES, HTML5_VALUE_MAP } from 'vscode-html-languageservice/lib/umd/languageFacts/data/html5';
import { HTML5_EVENTS } from 'vscode-html-languageservice/lib/umd/languageFacts/data/html5Events';
import { HTML5_TAGS } from 'vscode-html-languageservice/lib/umd/languageFacts/data/html5Tags';
It seems like that the data is now available like this:
import { htmlData } from 'vscode-html-languageservice/lib/umd/languageFacts/data/webCustomData';
htmlData
implements the public interface HTMLDataV1
so it contains events tags, global attributes, and a map.
Is there any possibility to make these default language facts public, so we can import them like import { htmlData } from 'vscode-html-languageservice';
?
We actually publish them to https://www.npmjs.com/package/vscode-web-custom-data, but it doesn't include the types. However it includes the data according to the JSON spec. Would adding d.ts to the vscode-web-custom-data
project work for your case?
If you are interested in raw data you should definitely import from vscode-web-custom-data
, not the internals of html LS.
Thank you for the info! I did not know about that package. I tried importing it like import htmlData from 'vscode-web-custom-data/data/browsers.html-data.json';
and it seems to work, although infered types are off a little (string
not assignable to MarkupKind
), but that's okay for me. But of course it would be great if you could add the types. Just to be sure: After that I would import the json like import { htmlData } from 'vscode-web-custom-data
?
I just published vscode-html-languageservice@3.1.which has
- New API
getDefaultHTMLDataProvider
to get the default HTML data provider - New API
newHTMLDataProvider
to create a new provider from data.