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

404 when importing type declaration files from pika.dev using Deno 1.0.2 #5876

Closed
njbraun opened this issue May 26, 2020 · 15 comments
Closed
Assignees
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@njbraun
Copy link

njbraun commented May 26, 2020

I have the following source code:

import * as pkg from 'https://cdn.pika.dev/node-fetch/^2.6.0';
console.log('PACKAGE:', pkg);

Running on latest (1.0.2) yields:

deno --version
deno 1.0.2
v8 8.4.300
typescript 3.9.2

deno run --reload <above_test>
Download https://cdn.pika.dev/node-fetch/^2.6.0
Download https://cdn.pika.dev/-/node-fetch@v2.6.0-AJHWZQobu33EvFJcmA2J/dist=es2019,mode=types/index.d.ts
Download https://cdn.pika.dev/-/node-fetch@v2.6.0-AJHWZQobu33EvFJcmA2J/dist=es2019/node-fetch.js
Download https://cdn.pika.dev/http/dist=es2019,mode=types/index.d.ts
Download https://cdn.pika.dev/url/dist=es2019,mode=types/index.d.ts
Download https://cdn.pika.dev/-/node-fetch@v2.6.0-AJHWZQobu33EvFJcmA2J/dist=es2019,mode=types/externals.d.ts
Download https://cdn.pika.dev/-/url@v0.11.0-4GEt8r64v6xtacsEmNHX/dist=es2019,mode=types/index.d.ts
Download https://cdn.pika.dev/-/http@v0.0.1-security/dist=es2019,mode=types/index.d.ts
error: Import 'https://cdn.pika.dev/-/url@v0.11.0-4GEt8r64v6xtacsEmNHX/dist=es2019,mode=types/index.d.ts' failed: 404 Not Found

FYI, the http and url packages do not exist on pika.dev. It seems like the request tries to get type definitions for all sub-dependencies, but fails if they do not exist.

Possibly related to: #5029 #5726

@bartlomieju

Also possibly relating to: skypackjs/skypack-cdn#3 and skypackjs/skypack-cdn#8

@jamesseanwright
Copy link
Contributor

Seeing the same thing in Deno 1.0.3:

error: Import 'https://cdn.pika.dev/-/@sinonjs/fake-timers@v6.0.1-JhTh9R3cBdH83IL6Lnpd/dist=es2019,mode=types/index.d.ts' failed: 404 Not Found

@bartlomieju bartlomieju self-assigned this Jun 1, 2020
@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels Jun 1, 2020
@jamesseanwright
Copy link
Contributor

@njbraun You could potentially migrate to jspm, which works for me:

import * as pkg from 'https://dev.jspm.io/node-fetch/^2.6.0';

@bartlomieju
Copy link
Member

bartlomieju commented Jun 1, 2020

I just triaged this issue - I can repeat the problem. Going to problematic url in the browser yields an HTTP 500 error:

https://cdn.pika.dev/-/http@v0.0.1-security/dist=es2019,mode=types/index.d.ts
Build Error: This package could not be built.

CC @FredKSchott can you check if that's a problem on your side?

@bartlomieju
Copy link
Member

Seeing the same thing in Deno 1.0.3:

error: Import 'https://cdn.pika.dev/-/@sinonjs/fake-timers@v6.0.1-JhTh9R3cBdH83IL6Lnpd/dist=es2019,mode=types/index.d.ts' failed: 404 Not Found

@jamesseanwright what was your entry point for this case? I get HTTP 404 in the browser for this type declaration as well - this might be a bug in parsing after all...

@jamesseanwright
Copy link
Contributor

I'm now using import sinon from "https://dev.jspm.io/sinon@7.5.0"; (Sinon is the overall dependency that then depends uponfake-timers).

@njbraun
Copy link
Author

njbraun commented Jun 1, 2020

import * as pkg from 'https://dev.jspm.io/node-fetch/^2.6.0';

While that does work:

➜  deno-test deno run --reload test.ts
Download https://dev.jspm.io/node-fetch
Download https://dev.jspm.io/npm:node-fetch@2.6.0/browser.dew.js
Compile fetch-test.ts
PACKAGE: [AsyncFunction: fetch]

There's no fetch any of the type definitions like what was happening w/ Pika. (Request Header: X-TypeScript-Types). A reasonable stop gap until Deno can provide better error handling when a dependency graph results in 404/500 dead ends.

@jamesseanwright
Copy link
Contributor

jamesseanwright commented Jun 2, 2020

@njbraun There's a potential fix for that:

// deps.ts

import * as jsNodeFetch from 'https://dev.jspm.io/node-fetch@2.6.0';
import { fetch as Fetch }  from 'https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/aaf0e9573304fcaa1daef91484c2fc5cebdbbcd0/types/node-fetch/index.d.ts'

// the binding to use throughout your code
export const nodeFetch: Fetch = jsNodeFetch;

Specific to your example, is there a reason you're pulling in node-fetch? Appreciate it might just be an example, but note that Deno provides fetch via the global window object.

@bartlomieju
Copy link
Member

I'm now using import sinon from "https://dev.jspm.io/sinon@7.5.0"; (Sinon is the overall dependency that then depends uponfake-timers).

@jamesseanwright I just tried running this example on latest master and it compiles without a problem - I think the problem was fixed #6000, but I'm gonna keep this issue open until 1.0.4 is released.

@jamesseanwright
Copy link
Contributor

I'll give it a whirl at some point in the next few days. Thanks for the update @bartlomieju! :)

@SquareMesh
Copy link

SquareMesh commented Jun 4, 2020

Not sure if I'm encountering same issue with the following import.

import {Button} from 'https://cdn.pika.dev/@material-ui/core@^4.10.1';

A slew of items are downloaded but fails with the following..

error: Import 'https://cdn.pika.dev/dist=es2019,mode=types/index.d.ts' failed: 404 Not Found

Tried on Deno 1.0.5, 1.0.4, 1.0.3.

@bartlomieju
Copy link
Member

@SquareMesh I just run your example and found the problematic type declaration. Downloading https://cdn.pika.dev/-/@material-ui/core@v4.10.1-fc2SiMnxs3PyrtZEG3jY/dist=es2019,mode=types/Card/Card.d.ts yields:

import * as React from '/-/react@v16.13.1-ByypZEPVPs6cpkpGdpQK/dist=es2019,mode=types/index.d.ts';
import { StandardProps } from '/../dist=es2019,mode=types/index.d.ts';
import { PaperProps } from '../Paper.d.ts';

export interface CardProps extends StandardProps<PaperProps, CardClassKey> {
  /**
   * If `true`, the card will use raised styling.
   */
  raised?: boolean;
}

export type CardClassKey = 'root';

/**
 *
 * Demos:
 *
 * - [Cards](https://material-ui.com/components/cards/)
 *
 * API:
 *
 * - [Card API](https://material-ui.com/api/card/)
 * - inherits [Paper API](https://material-ui.com/api/paper/)
 */
export default function Card(props: CardProps): JSX.Element;

Notice the second import: /../dist=es2019,mode=types/index.d.ts <--- effectively it always resolves to https://cdn.pika.dev/dist=es2019,mode=types/index.d.ts.

I think that might be problem originating in Pika, @FredKSchott can you confirm that it's expected import specifier?

@FredKSchott
Copy link

Yup, we just fixed that bug this weekend. I updated to Deno v1.1.0 and all type imports now resolve successfully.

Note that it looks like you need to have the "dom" lib added in your tsconfig from material-ui to compile properly.

@bartlomieju
Copy link
Member

Thanks @FredKSchott! Closing as resolved.

@Bidek56
Copy link

Bidek56 commented Jun 23, 2020

I am seeing a slightly different material-ui with deno 1.1.1 error:
error: 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', or 'yield' cannot be used as an identifier in strict mode at https://cdn.pika.dev/-/csstype@v2.6.10-9lGFwmNeuxj9xXremWKA/dist=es2019,mode=exports/index.d.ts:1:7,Expected Comma, got Some(Word(StandardLonghandProperties)) at https://cdn.pika.dev/-/csstype@v2.6.10-9lGFwmNeuxj9xXremWKA/dist=es2019,mode=exports/index.d.ts:1:17
Is this a deno or a library problem? Thx

@bartlomieju
Copy link
Member

@Bidek56 that's a different problem, please open a separate issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

6 participants